The Direct-To-COM (DTC) compiler is an Oberon compiler that supports Microsoft's Component Object Model (COM) binary interface standard. The "SaferOLE" technology adds automatic memory management to OLE objects. The seamless integration of COM into a dynamic, object-oriented language is a world premiere. The DTC compiler relieves programmers from cumbersome and error-prone manual memory management. Programs become more reliable and maintainable. COM Objects implemented with the DTC compiler can be used from any other language, and COM objects implemented in any language can be used from Oberon.
COM is the foundation of OLE. Reference counting errors are the number one source of errors when programming to the OLE interfaces. In contrast to C and C++, programmers using the DTC Oberon compiler do not need to worry about reference counting anymore. The compiler automatically calls an object's AddRef and Release methods where necessary. When a COM object is no longer used, it is automatically removed from memory.
With the DTC compiler, reference counting errors simply will not occur. COM objects can no longer produce memory leaks or dangling pointers. Debugging time can be cut back dramatically and applications reach the market earlier, with fewer defects. The tool can easily save weeks of debugging time, thus paying for itself in a short time.
In DTC Oberon, objects are declared and implemented in a superset of the Oberon language (see code sample below). The compiler implements a COM object's AddRef and Release methods automatically.
The compiler has built-in LONGCHAR and HUGEINT data types to support Unicode characters and 64-bit integers. It supports full 64-bit arithmetic.
The compiler is delivered with the Oberon/F integrated development environment. The debugger lets you inspect components and objects on a symbolic level. It uses hypertext links to visualize pointers, letting you browse through dynamic memory just like you surf on the Web.
Features
- Typesafe COM programming with automatic memory management
- Compiler calls object
s AddRef and Release methods automatically whenever necessary
- Compiler implements AddRef and Release methods of new objects automatically
- Default implementation of QueryInterface
- Unicode and 64-bit integer arithmetic support built into language
- out parameter classes
- NIL-compatible VAR parameters for efficient interfacing to C and C++
- Optimized debugger for symbolic inspection of objects
Relation Between DTC Oberon Compiler and Oberon/F
The DTC compiler is targeted at programmers who need to develop at the COM level. Typically, these programmers develop new OLE components, e.g. a new OLE control (OCX). They want full control over all COM features and no overhead. In turn they are accepting that they have to know all the intricacies of COM and the OLE APIs, that their code is non-portable, and that they have to give up some of the safety of an all-Oberon component. The DTC compiler retains as much of Oberon's safety as is possible with direct COM programming.
Most Oberon/F programmers never need to program at the COM level. For this reason, Oberon/F and the DTC compiler are independent product lines, although the DTC compiler actually uses a version of Oberon/F as its integrated development environment.
Oberon-COM Code Sample
The following example defines and implements the EnumX interface for rectangles. The type IEnumRECT defines the IEnumRECT interface. This type cannot be instantiated. The interface is implemented in the class EnumRECT.
Note, that both the AddRef and Release methods as well as the QueryInterface methods are implemented by the compiler.
The C++ code sample for exactly the same example is given below.
MODULE ComEnumRect;
(* adapted from EnumRect sample in "Inside OLE", 2nd ed. *)
(* 12.2.96 Oberon microsystems inc. *)
IMPORT COM, WinOle;
CONST rects = 15;
TYPE
PtrIEnumRECT* = POINTER TO IEnumRECT;
IEnumRECT* =
RECORD ["{00021140-0000-0000-C000-000000000046}"] (WinOle.IUnknown)